﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using QuickMenus;

namespace TestApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            var mainMenu = new Menu(name: "Main Menu", exitAlias: "exit");
            mainMenu.AddEntry(new[] { "time", "date" }, PrintTime.INSTANCE);
            mainMenu.AddEntry(new[] { "exists" }, Exists.INSTANCE);
            mainMenu.Operation(new string[0]);
        }

        private class Exists : MenuItem
        {
            public static readonly Exists INSTANCE = new Exists("File Exists");

            public Exists(string name)
                : base (name)
            {
                //Intenionally Left Blank
            }

            public override Func<string[], int> Operation
            {
                get
                {
                    return (t) => System.IO.File.Exists(t[0]) ? 1 : 0;
                }
            }
        }

        private class PrintTime : MenuItem
        {
            public static readonly PrintTime INSTANCE = new PrintTime("Current Time");

            public PrintTime(string name)
                : base (name)
            {
                //Intentionally Left Blank
            }

            public override Func<string[], int> Operation
            {
                get
                {
                    return (t) =>
                    {
                        Console.WriteLine(DateTime.Now);
                        return 0;
                    };
                }
            }
        }
    }
}
